/*----------------------------------------------------------------------------
Owner(s): Shane Whitfield
$Copyright: $
$Id: 

Purpose  : 
----------------------------------------------------------------------------*/

#pragma once

#include "singleton.h"
#include "bbmath.h"
#include "subsystem.h"
#include "nncommand.h"
#include <vector>

/*--------------------------------------------------------------------------*/
// Forward Declarations
class CGo;
class CGoNode;
class CGoMinerals;
class CGoPath;

/*--------------------------------------------------------------------------*/
#define MAX_GOS 100

/*--------------------------------------------------------------------------*/
// Class Enums
enum EClass
{
	EClass_Invaild = -1,
	
	//place-able
	EClass_HealStation,
	EClass_Nucleus,
	EClass_ExpansionNode,
	EClass_BasicWeapon,
	EClass_MiningStation,
	
	//spawnables
	EClass_Miner,
	EClass_Healer,
	EClass_Minerals,
	
	//enemies
	EClass_Swarmer,
	
	//other
	EClass_Path,
	
	EClass_Max
};


EClass ClassFromString(const char* i_classStr);

/*--------------------------------------------------------------------------*/

//This enum is sorted this way for rendering purposes. Moving an enum around,
// we 
enum EDepthLayer 
{
    BEGIN_ENUM(EDepthLayer_),
	
    EDepthLayer_UI,
	EDepthLayer_WorldExternal,
	EDepthLayer_GoEnemy,
    EDepthLayer_GoPlayer, 
    EDepthLayer_Vein,
	EDepthLayer_World1,
	EDepthLayer_World2,
	EDepthLayer_World3,
	EDepthLayer_World4,
	
	EDepthLayer_InvalidLayer,	//Used to push bad objects to.
    END_ENUM(EDepthLayer_)
};

/*--------------------------------------------------------------------------*/
// Class CGoMgr declartion
class CGoMgr : public TSingleton<CGoMgr>, public CSubsystem, public CCommandTaker
{
	typedef CSubsystem super;

public:
						CGoMgr();
					
	//CCommandTaker Overrides
	virtual const char*	GetName() const {
							return "gos"; }
	virtual void		On_Command(const char* i_command, const char* i_parameters);
			
	//subsystem overrides
	virtual void		OnPreWorldUnload();
			
	//basic system calls
	void				Render();
	void				Update();
	
	CGo*				CreateGo(EClass i_class, const Vector2f& i_pos);
	void				DestroyGo(CGo* i_go);
	void				On_UICreateGoPlacingNode(EClass i_spawnClass, const Vector2f& i_worldPos);
	void				On_UIDestoryCurrentGoPlacingNode();
	bool				On_IsGoPlacingNodePlaced() const;
	bool				IsTouchOfDeath() const {
							return m_isTouchOfDeath; }
	bool				IsANodePlacing() const {
							return m_goNodePlacing; }
	
	int					GetClassCost(EClass i_class) const;
	
	//later maybe we can make this more generic?
	bool				GetNearNodes(const Vector2f& i_center, float i_radius, std::vector<CGoNode*>& o_foundNodes);
	bool				GetNearNodesNotFullHealth(const Vector2f& i_center, float i_radius, std::vector<CGoNode*>& o_foundNodes);
	bool				GetNearConnectionProviderNodes(const Vector2f& i_center, float i_radius, std::vector<CGoNode*>& o_foundNodes, CGoNode* i_ignoreMe = NULL);
	bool				GetNearEnemies(const Vector2f& i_center, float i_radius, std::vector<CGo*>& o_foundEnemies);
	bool				GetNearMinerals(const Vector2f& i_center, float i_radius, std::vector<CGoMinerals*>& o_foundMinerals);
	CGoPath*			GetPathByName(const char* i_name);
	
    float               GetDepthFromDepthEnum(EDepthLayer i_depthLayer);
private:

	void				addGo(CGo* i_go);
	
	std::vector<CGo*>	m_gos;
	CGo*				m_touchedGo;
	bool				m_isTouchOfDeath;
	CGoNode*			m_goNodePlacing;
};
inline CGoMgr& CGoMgr_GetSingleton() { return CGoMgr::GetSingleton(); }
#define g_gomgr (CGoMgr_GetSingleton())

/*-----------------------------------EOF!-----------------------------------*/